﻿<%@ Page Language="C#" MasterPageFile="~/Navigations.Master" AutoEventWireup="true" CodeBehind="PayInfoManager.aspx.cs" Inherits="WeChat.Manager.PayInfoManager" Title="无标题页" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="../bootstrap-3.3.5-dist/js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () { 
        $("[data-toggle='tooltip']").tooltip();
        getWxPayInfo();
        getAliPayInfo();
        //微信支付基础信息配置
        $("#sendText").click(function(){
            var err=0;
            $("input.form-control").each(function(){
                if($(this).val()==""){
                    $(this).parents("[for='parent']").addClass("has-error");
                    $(this).parent("div").find("span").text("不能为空");err++;
                }else{
                    $(this).parents("[for='parent']").removeClass("has-error");
                    $(this).parent("div").find("span").text("");
                }
            });
            if(err>0)  return;
            var param={ 
              funcName:"setWxPayInfo",
              companyName:$("#companyName").val(),
              body:$("#body").val(),
              product_id:$("#product_id").val(),
              merchantNum:$("#merchantNum").val(),
              payKey:$("#payKey").val()
            };
            $.post("../WxHandler.ashx",param,function(data){
               if(data=="1"){
                  alert("微信支付基础信息配置成功");
               }else{
                  alert("微信支付基础信息配置失败");
               }
            });                                
        });

        //支付宝支付基础信息配置 
        $("#btnAliPay").click(function(){
             var err=0;
            $("input.form-control").each(function(){
                if($(this).val()==""){
                    $(this).parents("[for='parent2']").addClass("has-error");
                    $(this).parent("div").find("span").text("不能为空");err++;
                }else{
                    $(this).parents("[for='parent2']").removeClass("has-error");
                    $(this).parent("div").find("span").text("");
                }
            });
            if(err>0)  return;
            var param={
              funcName:"setAliPayInfo",
              alipay_public_key:$("#alipay_public_key").val(),
              merchant_private_key:$("#merchant_private_key").val(),
              merchant_public_key:$("#merchant_public_key").val(),
              appId:$("#appId").val(),
              pid:$("#pid").val()
            };
            $.post("../WxHandler.ashx",param,function(data){
              if(data=="1"){
                 alert("支付宝支付配置成功！");
              }else{
                 alert("支付宝支付配置失败！");
              }
            });
        });
    });
    function getWxPayInfo(){
        $.ajax({
            type:"post",
            url:"../WxHandler.ashx",
            data:{funcName:"getWxPayInfo"},
            success:function(data){
                if(data==null)return;
                data=$.parseJSON(data);
                $("#companyName").val(data[0].CompanyName);
                $("#body").val(data[0].body);
                $("#product_id").val(data[0].product_id);
                $("#merchantNum").val(data[0].merchantNum);
                $("#payKey").val(data[0].payKey);
            }
        });
    }
    function getAliPayInfo(){
        $.ajax({
            type:"post",
            url:"../WxHandler.ashx",
            data:{funcName:"getAliPayInfo"},
            success:function(data){
                if(data==null)return;
                data=$.parseJSON(data);
                $("#alipay_public_key").val(data[0].alipay_public_key);
                $("#merchant_private_key").val(data[0].merchant_private_key);
                $("#merchant_public_key").val(data[0].merchant_public_key);
                $("#appId").val(data[0].appId);
                $("#pid").val(data[0].pid);
            }
        });
    }
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="container">
    <div class="panel panel-info">
       <div class="panel-heading">
          <h3 class="panel-title">微信支付基础信息配置</h3>
       </div>
       <div class="panel-body">
       <form class="form-horizontal" role="form">
	        <div class="form-group" for="parent">
		        <label for="firstname" class="col-sm-3 control-label">商户名称</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="companyName" data-toggle="tooltip" data-placement="top" title="用户支付时展示的商户名称"
				           placeholder="请输入商户名称"><span style="color:Red" for="err"></span>
		        </div>
	        </div>
	        <div class="form-group" for="parent">
		        <label class="col-sm-3 control-label">商品或支付单简要描述</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="body" data-toggle="tooltip" data-placement="top" title="用户支付时展示的商品名称"
				           placeholder="请输入商品或支付单简要描述"><span style="color:Red" for="err"></span>
		        </div>
	        </div>
	        <div class="form-group" for="parent">
		        <label class="col-sm-3 control-label">商品ID(扫码支付必须)</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="product_id" data-toggle="tooltip" data-placement="top" title="用户扫描二维码支付的商品ID"
				           placeholder="请输入商品ID"><span style="color:Red" for="err"></span>
		        </div>
	        </div>
	        <div class="form-group" for="parent">
		        <label class="col-sm-3 control-label">商户号</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="merchantNum" data-toggle="tooltip" data-placement="top" title="申请微信支付后的微信商户号"
				           placeholder="请输入微信商户号" maxlength="32"><span style="color:Red" for="err"></span>
		        </div>
	        </div>
	        <div class="form-group" for="parent">
		        <label class="col-sm-3 control-label">商户密钥</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="payKey" data-toggle="tooltip" data-placement="top" title="申请微信支付后的商户key值，需先在商户后台手动设置:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置"
				           placeholder="请输入微信商户密钥"><span style=" color:Red" for="err"></span>
		        </div>
	        </div>
	    </form>
       </div>
       <div class="panel-footer text-left">          
          <input type="button" class="btn btn-primary"  id="sendText" value="保 存"/>
       </div>
    </div>
    <div class="panel panel-info">
       <div class="panel-heading">
          <h3 class="panel-title">支付宝支付基础信息配置</h3>
       </div>
       <div class="panel-body">
       <form class="form-horizontal" role="form">
	        <div class="form-group" for="parent2">
		        <label for="firstname" class="col-sm-3 control-label">支付宝公钥</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="alipay_public_key" data-toggle="tooltip" data-placement="top" title="支付宝应用填入开发者公钥后自动生成"
				           placeholder="请输入支付宝公钥"><span style="color:Red" for="err2"></span>
		        </div>
	        </div>
	        <div class="form-group" for="parent2">
		        <label class="col-sm-3 control-label">开发者私钥</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="merchant_private_key" data-toggle="tooltip" data-placement="top" title="支付宝RSA签名验签工具自动生成"
				           placeholder="请输入开发者私钥"><span style="color:Red" for="err2"></span>
		        </div>
	        </div>
	        <div class="form-group" for="parent2">
		        <label class="col-sm-3 control-label">开发者公钥</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="merchant_public_key" data-toggle="tooltip" data-placement="top" title="支付宝RSA签名验签工具自动生成"
				           placeholder="请输入开发者公钥"><span style="color:Red"  for="err2"></span>
		        </div>
	        </div>
	        <div class="form-group" for="parent2">
		        <label class="col-sm-3 control-label">应用ID</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="appId" data-toggle="tooltip" data-placement="top" title="支付宝应用ID"
				           placeholder="请输入应用ID(appId)"><span style="color:Red" for="err2"></span>
		        </div>
	        </div>
	        <div class="form-group" for="parent2">
		        <label class="col-sm-3 control-label">合作伙伴ID</label>
		        <div class="col-sm-8">
			        <input type="text" class="form-control" id="pid" data-toggle="tooltip" data-placement="top" title="支付宝合作伙伴ID partnerID"
				           placeholder="请输入合作伙伴ID(partnerID)"><span style="color:Red" for="err2"></span>
		        </div>
	        </div>
	    </form>
       </div>
       <div class="panel-footer text-left">
          <input type="button" id="btnAliPay" class="btn btn-primary" value="保 存" />        
       </div>
    </div>
</div>
</asp:Content>
